﻿using System;
using System.Globalization;

namespace Red.Scripts.Debugger.Defines
{
    public static class Utility
    {
        public static bool HasFlag<T>( T flags, T flag ) where T : IConvertible
        {
            int convertedFlags = flags.ToInt32( CultureInfo.CurrentCulture );
            int convertedFlag = flag.ToInt32( CultureInfo.CurrentCulture );

            return ( convertedFlags & convertedFlag ) != 0;
        }

        public static bool HasFlag<T>( uint flags, T flag ) where T : IConvertible
        {
            uint flagToTest = flag.ToUInt32( CultureInfo.CurrentCulture );

            return ( flags & flagToTest ) != 0;
        }
    }
}
